<?php
	header("Content-Type: application/json");
	include("../../include/dbconnect.php");
	$table="dvtmenumuc";
	$where="where chophep=1 and idmenumuc=".$_GET["idmenumuc"];
	if($_GET["q"]!="") $where="where (ten like '%".$_GET["q"]."%') and (chophep=1) and idmenumuc=".$_GET["idmenumuc"];
	$result=mysql_query("select * from $table $where",$conn);
	$n=mysql_num_rows($result);
	if($n<=0)
	{
		echo "{\"results\":[\n";
		echo "{\"id\":\"\",\"name\":\"\"}\n";
		echo "]}\n";
	}
	else
	{
		$i=1;	
		echo "{\"results\":[\n";
		for(;$a=mysql_fetch_array($result);)
		{
			echo "{\"id\":\"",$a["id"],"\",\"name\":\"",$a["ten"],"\"}";
			if($i==$n) echo "";
			else echo ",";
			echo "\n";
			$i++;
		}
		echo "]}\n";
	}
	mysql_free_result($result);
	include("../../include/dbclose.php");
?>